
corn = int(input())
peach = 0
while corn//3 != 0 :
    peach = corn // 3
    corn %= 3
    corn += peach 
print(corn)
